{extend name="public/base" /}
{block name="content"}

<style>
    .formDiv{
        height: 100%;
    }
    .blank{
        margin-bottom: 10%;
    }
    .el-pager li{
        font-size: 19px;
    }

</style>

<div class="formDiv">

    <div style="margin-top: 5%;float: left">资讯列表：</div>

    <input type="button" id="newsCreate" style="width: 30%;float: right" class="el-button el-button--primary"
           value="创建"/>

    <table class="el-table__body" style="width: 820px;border: 5px;margin-bottom: 10%;">
        <thead>
        <tr class="el-table_row">
            <th>ID</th>
            <th>文章标题</th>
            <th>所属栏目</th>
            <th>发布类型</th>
            <th>点赞数</th>
            <th>评论数</th>
            <th>是否轮播</th>
            <th>总体分数</th>
            <th>添加时间</th>
        </tr>
        </thead>
        <tbody>
        <?php if(sizeof($articleData) == 0){ ?>
        <tr>
            <td colspan="8" style="text-align: center;font-weight: bold">
                暂时没有数据
            </td>
        </tr>
        <?php }else{ ?>
        <?php foreach($articleData as $k => $v){ ?>
        <?php if($k%2 == 0){ ?>
        <tr class="el-table__row" style="background-color: #FDF5E6">
            <td class="el-table_1_column_10">
                <?php echo $v['id']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo cut_str($v['title'],10); ?>
            </td>
            <td class="el-table_1_column_10" style="color: #F56741;">
                <?php echo getClassName($v['cid']); ?>
            </td>
            <td class="el-table_1_column_10">
                <?php if($v['type'] == 1){ ?>
                    三图板式
                <?php }else if($v['type'] == 2){ ?>
                    左文右图
                <?php }else if($v['type'] == 3){ ?>
                    底部大图
                <?php } ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo $v['like_number']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo $v['comment_number']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php if($v['is_banner'] == 0){  ?>
                    普通文章
                <?php }else if($v['is_banner'] == 1){ ?>
                    头条轮播
                <?php } ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo $v['total_score']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo date('Y-m-d',$v['add_time']); ?>
            </td>
            <td class="el-table_1_column_10">
                <button onclick="delArticle(<?php echo $v['id']; ?>)" type="button" class="el-button el-button--primary" value="删除">
                    <i class="el-icon-delete">
                    </i>
                </button>
            </td>
        </tr>
        <?php }else{ ?>
        <tr class="el-table__row el-table__row">
            <td class="el-table_1_column_10">
                <?php echo $v['id']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo cut_str($v['title'],10); ?>
            </td>
            <td class="el-table_1_column_10" style="color: #F56741;">
                <?php echo getClassName($v['cid']); ?>
            </td>
            <td class="el-table_1_column_10">
                <?php if($v['type'] == 1){ ?>
                三图板式
                <?php }else if($v['type'] == 2){ ?>
                左文右图
                <?php }else if($v['type'] == 3){ ?>
                底部大图
                <?php } ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo $v['like_number']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo $v['comment_number']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php if($v['is_banner'] == 0){  ?>
                普通文章
                <?php }else if($v['is_banner'] == 1){ ?>
                头条轮播
                <?php } ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo $v['total_score']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo date('Y-m-d',$v['add_time']); ?>
            </td>
            <td class="el-table_1_column_10">
                <button onclick="delArticle(<?php echo $v['id']; ?>)" type="button" class="el-button el-button--primary" value="删除">
                    <i class="el-icon-delete">
                    </i>
                </button>
            </td>
        </tr>
        <?php } ?>
        <?php } ?>
        <?php } ?>
        </tbody>
    </table>

</div>

<div class="el-pager" style="margin-top: 10%;">
    {$page}
</div>

<script>
    $(document).ready(function() {
        $('#newsCreate').click(function(){
            location.href = "/index.php/index/index/newscreate";
        })


    });

    function delArticle(id){
        if(confirm("确定执行删除？")) {
            $.post("/index.php/index/Index/_delArticle", {id: id}, function (msg) {

                var msgArr = JSON.parse(msg);
                var status = msgArr.status;
                if (status == 1) {
                    alert(msgArr.msg);
                    location.href = "/index.php/index/Index/newsinfo";
                    return;
                } else {
                    alert(msgArr.msg);
                    return;
                }
            });
        }
    }
</script>

{/block}